// // 单证操作单元
import {Component, Prop, Vue} from 'vue-property-decorator'
import {store} from '@/store/index'


@Component({}) 
export default class btnResetPrint extends Vue{
    name:string ='btn-reset-print'


    @Prop()
    mod
    
    @Prop()
    btn

    @Prop()
    singleNumber
  
    @Prop()
    singleStatus
    
    
    get disabled (){
        return this.singleStatus !== '已集印'
    }

    render (h){

        let _vue = this;

        return (
            <i-button 
                disabled={_vue.disabled} 
                size='small'
                onClick={_vue.clickFn}
                type={_vue.btn.type}>
                {_vue.btn.title}
            </i-button>
        )

    }

    
    // 删除单证
    clickFn (){
        this.commitCurrentSingle(this.mod.key)

        store.dispatch('request', {
            url:'patch/single/id',
            data:{
                singleState: '分配集印'
            }
        })
        
    }

     // 提交当前操作项
    commitCurrentSingle(typeKey){
        store.commit('carFormStore/update', {
            target:'currentSingleType',
            data: typeKey
        })
    }
    
}